//
//  VenusTodoApp.swift
//  VenusTodo
//
//  Created by 文显庆 on 2021/10/7.
//

import SwiftUI

@main
struct VenusTodoApp: App {
    init() {
        Thread.sleep(forTimeInterval: 2.0) //延时执行函数,用于加载主页面的图片
        print("App初始化")
        //加载缓存中的数据
        if let data = UserDefaults.standard.data(forKey: "Tasks") {
            do {
                try Things = JSONDecoder().decode([ThingsTodo].self, from: data)
            } catch {
                print("Error")
            }
        }
        id_tag = Things.count
        
    }
    let persistenceController = PersistenceController.shared
    var body: some Scene {
        WindowGroup {
            Main()
                .environment(\.managedObjectContext, persistenceController.container.viewContext)
        }
    }
    
}
